import 'package:flutter/material.dart';
import 'package:flutter_meiqia/flutter_meiqia.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> with WidgetsBindingObserver {
  String _platformVersion = 'Unknown';
  @override
  void initState() {
    super.initState();
    WidgetsBinding.instance.addObserver(this);
    FlutterMeiQia.initMQ('e2b24e04bf68c9f1cd67afeac4ec6067').then((res) {
      print(res);
      // FlutterMeiQia.startMQ();
    });
  }

  @override
  void didChangeAppLifecycleState(AppLifecycleState state) {
    super.didChangeAppLifecycleState(state);
    switch (state) {
      case AppLifecycleState.resumed:
        // FlutterMeiQia.startMQ();
        break;
      case AppLifecycleState.inactive:
        // FlutterMeiQia.closeMQ();
        break;
      case AppLifecycleState.detached:
        break;
      case AppLifecycleState.paused:
        break;
      default:
    }
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
            child: Column(
          children: [
            RaisedButton(
              onPressed: () {
                FlutterMeiQia.pushToMQVC();
              },
              child: Text('Running on: $_platformVersion\n'),
            ),
          ],
        )),
      ),
    );
  }
}
